<template>
  <div class="market-page">
    <div class="header">
      <h1>📈 市场行情</h1>
      <p>实时市场数据和股票信息</p>
    </div>

    <!-- 测试区域：选股工具 -->
    <div class="test-section">
      <h2>🧪 选股工具测试</h2>
      <p>点击下方按钮测试选股功能</p>
      <StockSelector @stocks-selected="onStocksSelected" />
      
      <div v-if="selectedStocks.length > 0" class="selected-display">
        <h3>已选择的股票:</h3>
                    <div class="stock-list">
              <div 
                v-for="stock in selectedStocks" 
                :key="stock"
                class="stock-item"
              >
                <span class="stock-code">{{ stock.replace('.US', '') }}</span>
                <span class="stock-type">{{ getStockType(stock) }}</span>
              </div>
            </div>
      </div>
    </div>

    <!-- 原有的市场内容 -->
    <div class="market-content">
      <div class="market-card">
        <h3>📊 市场概览</h3>
        <p>这里是市场数据展示区域</p>
      </div>
    </div>
  </div>
</template>

<script>
import StockSelector from '@/components/StockSelector.vue'

export default {
  name: 'Market',
  components: {
    StockSelector
  },
  data() {
    return {
      selectedStocks: []
    }
  },
  methods: {
    onStocksSelected(stocks) {
      this.selectedStocks = stocks
      console.log('Market页面收到选择的股票:', stocks)
    },
    
    getStockType(stockCode) {
      // 根据股票代码判断类型
      const leverageStocks = ['BOIL', 'SOXL', 'TQQQ', 'SPXL', 'SPXS', 'TECL', 'TECS', 'FAS', 'FAZ']
      const code = stockCode.replace('.US', '')
      
      if (leverageStocks.includes(code)) {
        return '杠杆ETF'
      } else if (['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'TSLA', 'META', 'NVDA'].includes(code)) {
        return '科技股'
      } else {
        return '其他'
      }
    }
  }
}
</script>

<style scoped>
.market-page {
  padding: 20px;
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.header {
  text-align: center;
  margin-bottom: 30px;
  color: #333;
}

.header h1 {
  margin: 0 0 10px 0;
  font-size: 32px;
  font-weight: 700;
}

.header p {
  margin: 0;
  color: #666;
  font-size: 16px;
}

.test-section {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.test-section h2 {
  margin: 0 0 8px 0;
  color: #333;
  font-size: 20px;
  font-weight: 600;
}

.test-section p {
  margin: 0 0 16px 0;
  color: #666;
}

.selected-display {
  margin-top: 20px;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.selected-display h3 {
  margin: 0 0 12px 0;
  color: #333;
  font-size: 16px;
  font-weight: 600;
}

.stock-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stock-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #667eea;
  color: white;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
}

.stock-code {
  font-weight: 600;
}

.stock-type {
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 6px;
  border-radius: 8px;
  font-size: 10px;
}

.market-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.market-card h3 {
  margin: 0 0 16px 0;
  color: #333;
  font-size: 18px;
  font-weight: 600;
}

.market-card p {
  margin: 0;
  color: #666;
}

@media (max-width: 768px) {
  .market-page {
    padding: 10px;
  }
  
  .header h1 {
    font-size: 24px;
  }
  
  .test-section, .market-content {
    padding: 16px;
  }
}
</style> 